!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jssPluginNested={})}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=/\s*,\s*/g,r=/&/g,o=/\$([\w-]+)/g;e.default=function(){function e(e,t){return function(n,r){var o=e.getRule(r)||t&&t.getRule(r);return o?o.selector:r}}function i(e,t){for(var o=t.split(n),i=e.split(n),l="",s=0;s<o.length;s++)for(var u=o[s],f=0;f<i.length;f++){var a=i[f];l&&(l+=", "),l+=-1!==a.indexOf("&")?a.replace(r,u):u+" "+a}return l}function l(e,n,r){if(r)return t({},r,{index:r.index+1});var o=e.options.nestingLevel;o=void 0===o?1:o+1;var i=t({},e.options,{nestingLevel:o,index:n.indexOf(e)+1});return delete i.name,i}return{onProcessStyle:function(n,r,s){if("style"!==r.type)return n;var u,f,a=r,c=a.options.parent;for(var d in n){var p=-1!==d.indexOf("&"),v="@"===d[0];if(p||v){if(u=l(a,c,u),p){var g=i(d,a.selector);f||(f=e(c,s)),g=g.replace(o,f);var y=a.key+"-"+d;"replaceRule"in c?c.replaceRule(y,n[d],t({},u,{selector:g})):c.addRule(y,n[d],t({},u,{selector:g}))}else v&&c.addRule(d,{},u).addRule(a.key,n[d],{selector:a.selector});delete n[d]}}return n}}},Object.defineProperty(e,"__esModule",{value:!0})}));
